//
//  FileDirRespose.m
//  ICrEAM
//
//  Created by mac on 16/11/22.
//  Copyright © 2016年 mac. All rights reserved.
//

#import "FileDirRespose.h"

@implementation FileDirRespose
-(instancetype)init{
    self=[super init];
    if(self){
        
        [FileDirRespose mj_setupObjectClassInArray:^NSDictionary *{
            return @{ @"files":[FileDirRespose class]};
        }];
    }
    return self;
}
+ (NSDictionary *)replacedKeyFromPropertyName{
    return @{
             @"files" : @"FILES",
             @"is_dir" : @"IS_DIRECTORY",
             @"filePath" : @"FILE_PATH",
             @"fileName" : @"FILE_NAME"
             };
}
//12781001 是
-(BOOL)isDir{
    if ([_is_dir isEqualToString:@"12781001"]) {
        return YES;
    }
    return NO;
}
-(DocumentType)documentType{
    if (self.isDir) {
        return DirType;
    }else{
        NSString *str=self.filePath.lastPathComponent;
      NSRange range=[str rangeOfString:@"."];
        if (range.length!=0) {
            NSString *sufferStr=[str substringFromIndex:range.location+1];
            if ([sufferStr isEqualToString:@"docx"]) {
                return WordType;
            }
            if ([sufferStr isEqualToString:@"xls"]) {
                return ExcelType;
            }
            if ([sufferStr isEqualToString:@"txt"]) {
                return TxtType;
            }
            if ([sufferStr isEqualToString:@"pptx"]) {
                return PptType;
            }
            if ([sufferStr isEqualToString:@"pdf"]) {
                return PdfType;
            }
            if ([sufferStr isEqualToString:@"jpeg"]||[sufferStr isEqualToString:@"jpg"]) {
                return ImageType;
            }
            if ([sufferStr isEqualToString:@"aac"]) {
                return MusicType;
            }
        }
    }
    return OtherType;
}
-(NSString *)filePath{
    NSString *str=[NSString stringWithFormat:@"http://%@",[[ICreamCache sharedInstance] stringForKey:kIPPath]];
    return [NSString stringWithFormat:@"%@%@%@",str,@"/INFO_ICREAM_WEB/App/downLoadFile?filePath=/",_filePath];
}
@end
